﻿using BussinessObject.ObjectTwo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProjectHK3.App_Code;
using DataAccess.ObjectTwo;

namespace ProjectHK3.Object_One
{
    public partial class Distance : System.Web.UI.Page
    {
        B_LoadGidAD ex = new B_LoadGidAD();
        B_AdminDetail fx = new B_AdminDetail();
        DataTable tb = new DataTable();
        B_Delete cf = new B_Delete();
        D_GetAccount dg = new D_GetAccount();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                load();


            }

        }
        public void load()
        {
            tb = ex.loadDis();
            Label8.Text = tb.Rows.Count.ToString();
            GridView1.DataSource = tb;
            GridView1.DataBind();
             
        }

        protected void _lbtDelete_Command(object sender, CommandEventArgs e)
        {

            if (e.CommandName == "RemoveDistance")
            {


                Session["Distance"] = Convert.ToInt32(e.CommandArgument.ToString());
                if (cf.DeleteDis(Convert.ToInt32(Session["Distance"].ToString())) == true)
                {
                    Alert.Show("Delete Successful");
                    load(); 
                }
                else
                {
                    Alert.Show("Delete fail!!!");
                }

            }
          
        }

        protected void _lbtDetails_Command(object sender, CommandEventArgs e)
        {
            Session["Distances"] = Convert.ToInt32(e.CommandArgument.ToString());
       
            Response.Redirect("../Object One/DistanceDetail.aspx");
        }

        protected void _lbtDetails_Click(object sender, EventArgs e)
        {

        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            tb = dg.SearchDis(float.Parse(TextBox1.Text.ToString()), float.Parse(TextBox2.Text.ToString()));
            GridView1.DataSource = tb;
            GridView1.DataBind();
            Label8.Text = tb.Rows.Count.ToString();
        }
    }
}